package thinkingJava.chapter13;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JGrep {
	public static void main(String[] args) {
		String regex = "(\\s+|^)[Sxct]\\w+";
		Pattern p = Pattern.compile(regex);
		int index = 0;
		Matcher m = p.matcher("");
		for (String line : new String[]{"School","in the china","zhongsou","xuexiao","education","edu","com"}) {
			m.reset(line);
			while (m.find()) {
				System.out.println(index++ + " : " + m.group().replaceAll("\\s+", "") + " " + m.start());
			}
		}
	}
}
